<!DOCTYPE html>

<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
    <script th:src="@{/echarts/echarts.min.js}"></script>
    <script th:src="@{/echarts/world.js}"></script>
    <script th:src="@{/echarts/jquery-1.11.1.min.js}"></script>
    <link rel="stylesheet" th:href="@{./layui/css/layui.css}" media="all">
    <script th:src="@{./layui/layui.js}" charset="utf-8"></script>
</head>
<body class="childrenBody">

    <div>
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
        <!--  为echarts准备的dom  -->
        <div id="main" style="width: 900px; height: 700px"></div>
    </div>
</div>


<script type="text/javascript">

    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    // window.dataList = [];
    var datalist = [];
    option = {
        title: {
            text: '新型冠状病毒肺炎疫情地图',
            subtext: '累计确诊人数',
            left: 'center',
            top: 'top'
        },
        tooltip: {
            trigger: 'item',
            formatter: function (params) {
                var value = params.value + '';
                return params.seriesName + '<br/>' + params.name + ' : ' + value + '人';
            }
        },
        toolbox: {
            show: true,
            orient: 'vertical',
            left: 'right',
            top: 'center',
            feature: {
                dataView: {
                    readOnly: false
                },
                restore: {},
                saveAsImage: {}
            }
        },
        visualMap: {
            min: 0,
            max: 2200000,
            bottom: 100,
            text: ['High', 'Low'],
            realtime: false,
            calculable: true,
            color: ['orangered', 'yellow', 'lightskyblue']
        }
    };

    $.ajax({
        url: "/queryGlobal",
        dataType: "json",
        success: function (data) {
            for (let i in data) {
                datalist[i] = data[i];
            }
            myChart.setOption({
                series: [{
                    name: '新型冠状病毒肺炎疫情地图',
                    type: 'map',
                    mapType: 'world',
                    roam: true,
                    itemStyle: {
                        emphasis: {
                            label: {
                                show: true
                            }
                        }
                    },
                    data: datalist
                }]
            })
        }
    });

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
</script>

</body>
</html>